import config from './config/index'
import './utils/wxFun';
import './utils/index';
import './api/index'
App({
    config,
    onLaunch() {
        this.checkForUpdate()
        const that = this
        let token = ''
        try {
            token = wx.getStorageSync('token')
        } catch {
        }
        if (token) {
            that.globalData.isLogin = true;

        }
    },
    globalData: {
        userInfo: null,
        isLogin: false, // 是否已经登录了
    },
    // 更新
    checkForUpdate: function () {
        const updateManager = wx.getUpdateManager()
        updateManager.onUpdateReady(function () {
            wx.showModal({
                title: '更新提示',
                content: '新版本已经准备好，立即重启升级！',
                showCancel: false,
                success: function (res) {
                    if (res.confirm) {
                        updateManager.applyUpdate()
                    }
                }
            })
        })
        updateManager.onUpdateFailed(function () { })
    },
})
